package com.itheima.thread.卖票案例;

public class TicketThread extends Thread {
    private static int ticketCount = 100;
    @Override
    public void run() {
        while (true){
            synchronized ("abc"){
                if (ticketCount <= 0){
                    break;
                }else {
                    try {
                        Thread.sleep(500);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(Thread.currentThread().getName() + "正在卖票,还剩" + --ticketCount + "张");
                }
            }
        }
    }
}
